package center

import (
	"barge/app"
	"github.com/rs/zerolog/log"
	"github.com/spf13/cobra"
	"github.com/spf13/viper"
)

// listCmd represents the base command when called without any subcommands
var listCmd = &cobra.Command{
	Use: "list",
	Aliases: []string{
		"ls",
	},
	Short: "展示已配置的中转服务器配置",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		m, err := app.NewConfigManager(viper.GetString("configPath"))
		if err != nil {
			log.Err(err).Str("path", viper.GetString("configPath")).Send()
			return
		}
		m.ListCenter()
	},
}

func init() {
	centerCmd.AddCommand(listCmd)
}
